/**
 * User: Phil
 * Date: 10/13/11
 * Time: 7:29 PM
 */

//Base card image path
CARD_IMAGE_DIR = "images/cards/";

//Card types - may have more than one
var CardTypes = {
	ACTION: {value: 0, code: "ACTION", name: "Action"},
	ATTACK: {value: 1, code: "ATTACK", name: "Attack"},
	VICTORY: {value: 2, code: "VICTORY", name: "Victory"},
	REACTION: {value: 3, code: "REACTION", name: "Reaction"},
	TREASURE: {value: 4, code: "TREASURE", name: "Treasure"},
	DURATION: {value: 5, code: "DURATION", name: "Duration"},
	KINGDOM: {value: 6, code: "KINGDOM", name: "Kingdom"},
	CURSE: {value: 7, code: "CURSE", name: "Curse"}
};

var Card = Class.extend({
	//Methods
	init: function(name, cost, duration, image, quantity){
		this.name = name;
		this.cost = cost;
		this.duration = duration;
		this.imageFilename = image;
		this.quantity = (quantity) ? quantity : 10;   //Default 10

		//Attributes
		this.types = new Array();
		this.effects = new Array();

		//Net static effect on turn resources
		this.action = null;
		this.buy = null;
		this.card = null;
		this.money = null;
	},
	hasType: function(type) {
		return this.types.indexOf(type) >= 0;
	},
	getImagePath: function() {
		return CARD_IMAGE_DIR + this.imageFilename;
	},
	getEffectsHTML: function() {
		var html = "";

		$.each(this.effects, function(index, value) {
			html += '<div class="effect">';
			html += value.description;
			html += '</div>';
		});

		return html;
	},
	toHTML: function() {
		return  '<div class="card">' +
					'<img src="' + this.getImagePath() + '"/>' +
					//'<div class="caption">' + this.getEffectsHTML() + '</div>' +
				'</div>';
	}
});